﻿using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Xml.Linq;

namespace SharePointUtilitiesForDevelopers
{
    /// <summary>
    /// A domain class that represents a SharePoint list.
    /// </summary>
    [ReadOnly(true)]
    [DefaultProperty("Title")]
    public class SharePointList
    {
        /// <summary>
        /// Gets or sets the title.
        /// </summary>
        /// <value>The title.</value>
        [Description("The list title.")]
        public string Title { get; set; }

        /// <summary>
        /// Gets or sets the description.
        /// </summary>
        /// <value>The description.</value>
        [Description("The list description.")]
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets the type of the base.
        /// </summary>
        /// <value>The type of the base.</value>
        [Description("The list base type.")]
        public SharePointListBaseType BaseType { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name.</value>
        [Description("The GUID that indentifies the list.")]
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        /// <value>The id.</value>
        [Description("The GUID that identifies the list.")]
        public string Id { get; set; }

        /// <summary>
        /// Gets or sets the default view url.
        /// </summary>
        /// <value>The default view url.</value>
        [Description("The url of the default view.")]
        public string DefaultViewUrl { get; set; }

        /// <summary>
        /// Gets or sets the definition.
        /// </summary>
        /// <value>The definition.</value>
        [Description("The XML definition for the list.")]
        public XElement Definition { get; set; }

        /// <summary>
        /// Gets or sets the fields.
        /// </summary>
        /// <value>The fields.</value>
        [Description("The fields in the list.")]
        public ReadOnlyCollection<SharePointField> Fields { get; set; }

        /// <summary>
        /// Gets or sets the custom fields (not in a content type).
        /// </summary>
        /// <value>The custom fields.</value>
        [Description("The custom fields in the list (not in a site column or content type).")]
        public ReadOnlyCollection<SharePointField> CustomFields { get; set; }

        /// <summary>
        /// Gets or sets the content types.
        /// </summary>
        /// <value>The content types.</value>
        [Description("The content types in the list.")]
        public ReadOnlyCollection<SharePointContentType> ContentTypes { get; set; }

        /// <summary>
        /// Gets or sets the list views.
        /// </summary>
        /// <value>The list views.</value>
        [Description("The views in the list.")]
        public ReadOnlyCollection<SharePointListView> Views { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="SharePointList"/> is hidden.
        /// </summary>
        /// <value><c>true</c> if hidden; otherwise, <c>false</c>.</value>
        [Description("Indicates if the list is hidden.")]
        public bool Hidden { get; set; }

        /// <summary>
        /// Gets or sets the default view.
        /// </summary>
        /// <value>The default view.</value>
        [Description("The default view of the list.")]
        public SharePointListView DefaultView { get; set; }

        /// <summary>
        /// Gets or sets the version.
        /// </summary>
        /// <value>The version.</value>
        [Description("The list version.")]
        public string Version { get; set; }
        
        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            return string.Format("{0}", Title);
        }

    }
}